// LVJ submission #65af2abfd14038f289ef5963@1705978560317
#include<bits/stdc++.h>
#define gc getchar()
#define ll unsigned
using namespace std;
int n,k;
ll A,b,c,d,ans=-1;
ll a[100010];
map<ll,bool> mp;
int main() {
cin>>n>>k;
for(int i=1; i<=n; i++) {
cin>>A,gc;
cin>>b,gc;
cin>>c,gc;
cin>>d;
a[i]=(A<<24)+(b<<16)+(c<<8)+d;
}
ll now=UINT_MAX;
for(int i=1; i<=31; i++) {
now-=(1<<i-1);
int cnt=0;
mp.clear();
for(int j=1; j<=n; j++) if(!mp[now&a[j]]) mp[now&a[j]]=1,cnt++;
if(cnt==k) ans=now;
}
if(ans==-1) cout<<"-1";
else cout<<((ans>>24))<<"."<<((ans>>16)&255)<<"."<<((ans>>8)&255)<<"."<<(ans&255);
return 0;
}
1646B - Quality vs Quantity | 80A - Panoramix's Prediction |
1354B - Ternary String | 122B - Lucky Substring |
266B - Queue at the School | 1490A - Dense Array |
1650B - DIV + MOD | 1549B - Gregor and the Pawn Game |
553A - Kyoya and Colored Balls | 1364A - XXXXX |
1499B - Binary Removals | 1569C - Jury Meeting |
108A - Palindromic Times | 46A - Ball Game |
114A - Cifera | 776A - A Serial Killer |
25B - Phone numbers | 1633C - Kill the Monster |
1611A - Make Even | 1030B - Vasya and Cornfield |
1631A - Min Max Swap | 1296B - Food Buying |
133A - HQ9+ | 1650D - Twist the Permutation |
1209A - Paint the Numbers | 1234A - Equalize Prices Again |
1613A - Long Comparison | 1624B - Make AP |
660B - Seating On Bus | 405A - Gravity Flip |